package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.GpDashboardDetail;
import com.stylefeng.guns.modular.system.service.IGpDashboardDetailService;

/**
 * dashboard_detail控制器
 *
 * @author fengshuonan
 * @Date 2018-07-19 23:02:46
 */
@Controller
@RequestMapping("/gpDashboardDetail")
public class GpDashboardDetailController extends BaseController {

    private String PREFIX = "/system/gpDashboardDetail/";

    @Autowired
    private IGpDashboardDetailService gpDashboardDetailService;

    /**
     * 跳转到dashboard_detail首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "gpDashboardDetail.html";
    }

    /**
     * 跳转到添加dashboard_detail
     */
    @RequestMapping("/gpDashboardDetail_add")
    public String gpDashboardDetailAdd() {
        return PREFIX + "gpDashboardDetail_add.html";
    }

    /**
     * 跳转到修改dashboard_detail
     */
    @RequestMapping("/gpDashboardDetail_update/{gpDashboardDetailId}")
    public String gpDashboardDetailUpdate(@PathVariable Integer gpDashboardDetailId, Model model) {
        GpDashboardDetail gpDashboardDetail = gpDashboardDetailService.selectById(gpDashboardDetailId);
        model.addAttribute("item",gpDashboardDetail);
        LogObjectHolder.me().set(gpDashboardDetail);
        return PREFIX + "gpDashboardDetail_edit.html";
    }

    /**
     * 获取dashboard_detail列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return gpDashboardDetailService.selectList(null);
    }

    /**
     * 新增dashboard_detail
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(GpDashboardDetail gpDashboardDetail) {
        gpDashboardDetailService.insert(gpDashboardDetail);
        return SUCCESS_TIP;
    }

    /**
     * 删除dashboard_detail
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer gpDashboardDetailId) {
        gpDashboardDetailService.deleteById(gpDashboardDetailId);
        return SUCCESS_TIP;
    }

    /**
     * 修改dashboard_detail
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(GpDashboardDetail gpDashboardDetail) {
        gpDashboardDetailService.updateById(gpDashboardDetail);
        return SUCCESS_TIP;
    }

    /**
     * dashboard_detail详情
     */
    @RequestMapping(value = "/detail/{gpDashboardDetailId}")
    @ResponseBody
    public Object detail(@PathVariable("gpDashboardDetailId") Integer gpDashboardDetailId) {
        return gpDashboardDetailService.selectById(gpDashboardDetailId);
    }
}
